Namespace persistent
    Public Class corporateDealer

        Public Shared Function getListData() As DataTable
            Dim SQL As String

            SQL = " select cu.customer_id CUSTID ,cu.custcode||' '||cc.cclname  CORP from  customer_all cu,ccontact_all cc"
            SQL = SQL & " where cc.customer_id=cu.customer_id"
            SQL = SQL & " and cc.ccbill='X'"
            SQL = SQL & " and cu.custcode like '45%'"

            Return myDBConn.myORATable(SQL)
        End Function

        Public Shared Function getCorpDealer(ByVal dealer_id As String) As DataTable
            Dim SQL As String

            SQL = "SELECT * FROM ittemp.corp_dealers where corp_dealer_id=" & dealer_id
            Return myDBConn.myORATable(SQL)

        End Function

        Public Shared Function getDealerCount(ByVal custcode As String) As DataTable
            Dim SQL As String

            SQL = "select * from dealer where custcode='" & custcode & "'"
            Return myDBConn.myORATable(SQL)

        End Function


        Public Shared Function insertCorpDealer(ByVal dealer_id As String, ByVal dealer_code As String, ByVal user As String) As Long
            Dim SQL As String

            SQL = "insert into ittemp.corp_dealers  values (" & dealer_id & ",'" & dealer_code & "','" & user & "',sysdate)"

            Return myDBConn.ORAExecute(SQL)

        End Function

        Public Shared Function getDataGrid() As DataTable
            Dim SQL As String

            SQL = " SELECT cus.custcode||' '||cc.CCLNAME cname,corp.dealer_code  code"
            SQL = SQL & " FROM ittemp.corp_dealers corp,customer_all cus,ccontact_all cc"
            SQL = SQL & " where cc.customer_id=cus.customer_id"
            SQL = SQL & " and cus.customer_id=corp.CORP_DEALER_ID"
            SQL = SQL & " and cc.ccbill='X' and cus.customer_id<1"

            Return myDBConn.myORATable(SQL)
        End Function

    End Class
End Namespace
